/**
 *====================================================
 * 文件名称: BulkstockLatestgatherServiceImpl.java
 * 修订记录：
 * No    日期				作者(操作:具体内容)
 * 1.    2015年10月21日	chenxy(创建:创建文件)
 *====================================================
 * 类描述：(说明未实现或其它不应生成javadoc的内容)
 */
package com.yuexunit.finance.bulkstock.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.bulkstock.entity.BulkstockLatestGatherEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.page.PageCriteria;
import com.yuexunit.page.PageList;
import com.yuexunit.persist.PersistUtil;

/**
 * @ClassName: BulkstockLatestgatherServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年10月21日 15:53:33
 */
@Implements(BulkstockLatestGatherService.class)
public class BulkstockLatestGatherServiceImpl implements BulkstockLatestGatherService {

	@Override
	public PageList<BulkstockLatestGatherEntity> inquireBulkstockLatestgatherPageList(Long categoryId, Long bulkstockInfoId, String bulkstockName, String specification, PageCriteria page) {
		DetachedCriteria criteria = DetachedCriteria.forClass(BulkstockLatestGatherEntity.class);
		if (categoryId != null) {
			criteria.add(Restrictions.eq("categoryId", categoryId));
		}
		if (bulkstockInfoId != null) {
			criteria.add(Restrictions.eq("bulkstockInfoId", bulkstockInfoId));
		}
		if (bulkstockName != null) {
			criteria.add(Restrictions.like("bulkstockName", "%" + bulkstockName + "%"));
		}
		if (specification != null) {
			criteria.add(Restrictions.like("specification", "%" + specification + "%"));
		}
		return PersistUtil.get(criteria, page);
	}

	@Override
	public BulkstockLatestGatherEntity inquireBulkstockLatestgather(Long bulkstockInfoId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(BulkstockLatestGatherEntity.class);
		criteria.add(Restrictions.eq("bulkstockInfoId", bulkstockInfoId));
		List<BulkstockLatestGatherEntity> list = PersistUtil.get(criteria);
		if (list.isEmpty()) {
			return null;
		}
		return list.get(0);
	}

}
